package com.youu.youu.manager.controller;

import java.util.List;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.youu.youu.manager.bean.TPermiss;
import com.youu.youu.manager.service.PermissBackstageService;

/**
 * 
 * @ClassName DispatchPageController
 * @Description TODO(用于转发页面)
 * @author Thruman
 * @Date 2017年8月11日 下午2:22:59
 * @version 1.0.0
 */
@Controller
public class DispatchPageController {
	public static final String BACKSTAGE_MANAGER = "manager";
	public static final String PROCESS_PERMIS = "processPermiss";

	@Autowired
	PermissBackstageService pBackstageService;
	
	
	@RequestMapping("/index.html")
	public String dispatchIndex() {
		// 根据用户对应角色刷出权限
		Subject subject = SecurityUtils.getSubject();
		String loginacct = (String) subject.getPrincipal();
		List<TPermiss> allPermiss = pBackstageService
				.getAllPermissByRole(loginacct);
		Session session = subject.getSession();
		session.setAttribute(DispatchPageController.PROCESS_PERMIS, allPermiss);
		return "index";
	}

}
